
from rest_framework import serializers

from games.models import UserRecord, PlatformRecord

class PlatformRecordSerializer(serializers.ModelSerializer):
    """
   平台记录序列化
    """
    nper = serializers.CharField(source='userrecord.nper')
    isbigs = serializers.CharField(source='get_isbigs_display')
    class Meta:
        model = PlatformRecord
        fields = ['id','nper','isbigs','num','add_time']
        # fields = '__al__'



class PlatSerializer(serializers.ModelSerializer):
    """
   平台记录序列化
    """
    isbigs = serializers.CharField(source='get_isbigs_display')
    nper = serializers.CharField(source='userrecord.nper')
    class Meta:
        model = PlatformRecord
        fields = ['nper','isbigs']

class UserRecordSerializer(serializers.ModelSerializer):
    """
    用户记录序列化
    """
    status = serializers.CharField(source='get_status_display')
    # # isbigs = serializers.CharField(source='userrecord')
    small_big = serializers.CharField(source='get_small_big_display')
    iswining = serializers.CharField(source='get_iswining_display')
    userrecord = PlatSerializer(many=True)

    class Meta:
        model = UserRecord
        fields = ['id','token','small_big','iswining','count','beton','payoff','nper','status','userrecord','add_time']




